<template>
    <lay-button-group>
        <lay-button type="primary" size="xs" @click="handleClick('addconnect')">新增连接</lay-button>
    </lay-button-group>
    <lay-tree
        :data="storeMain.connect.connecttree_data"
        :tail-node-icon="false"
        :onlyIconControl="true"
        v-model:selectedKey="storeMain.connect.connecttree_selectedKey"
        @node-click="handleTreeClick"
    >
    </lay-tree>
    <connect_edit></connect_edit>
</template>
<script setup>
import connect_edit from './connect_edit.vue'
import {ref} from 'vue'
import {useStoreMain} from '../../store/storeindex.js';
const storeMain = useStoreMain();

function handleClick(type) {
    if (type == 'addconnect') {
        storeMain.connect.dialog_show = true;
    }
}
function handleTreeClick(node) {
    // console.log(node);
    // console.log(node.sqltype);
    // console.log(node.address);
    if(node.sqltype=='database'){
        storeMain.connect.selectDatabase(node);
    }else{
        storeMain.connect.initConnect(node);
    }
}
</script>
<style lang="scss" scoped>
.connleftmenu {
    width: 40px;
    height: 100%;
    background-color: var(--base_color);
    display: flex;
    flex-flow: column nowrap;
    justify-content: start;
    align-items: start;
    .box {
        display: flex;
        flex-flow: column nowrap;
        justify-content: center;
        align-items: center;
        margin-top: 20px;
        border: 0px solid #000;
        a {
            margin: 10px 5px;
        }
    }
}
.is-active {
    background-color: #605eda;
}
</style>
